package logic;

import java.util.Arrays;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: SmartBoy
 * @Date: 2021/07/26/18:03
 * @Description:
 */
public class test {
    public static void print(Block[] blocks) {
        for (int i = 0; i < 10; i++) {
            //System.out.println(blocks[i]);
        }
    }

    public static void main(String[] args) {
        FileSystem fileSystem = FileSystem.getInstance();
        System.out.println(fileSystem.fileMap);
        printTree(fileSystem.root,"  ");
        fileSystem.root.getChildList().forEach(file -> {
            //System.out.println(file);
            //System.out.println((String)fileSystem.openFile(file).getObj());
        });
        for(int i=0;i<=8;i++){
            //System.out.println(fileSystem.blocks[i].data);
        }


//        Block block = new Block();
//        block.id = 1;
//        System.out.println(block.data);
//        block.data = "nihao".toCharArray();
//        System.out.println(block.data);
//
//
//        FileSystem fileSystem = FileSystem.getInstance();
//
//
//        System.out.println(fileSystem.blocks[2]);
//
//        System.out.println(fileSystem.root);
//        System.out.println(fileSystem.createFile("123", "txt", 4));
//        System.out.println(fileSystem.createFile("123", "tat", 4));
//        System.out.println(fileSystem.createFile("123", "tbt", 4));
//        System.out.println(fileSystem.createFile("123", "tct", 4));
//        System.out.println(fileSystem.createFile("123", "tdt", 4));
//        System.out.println(fileSystem.createFile("123", "tet", 4));
//        System.out.println(fileSystem.openFile("123", "txt"));
//        System.out.println(fileSystem.openFile("123", "tat"));
//
//
//        System.out.println(fileSystem.writeFile("123", "txt", "123456781234567812345678123456781234567812345678123456781234567812", true));
//        System.out.println(fileSystem.writeFile("123", "tat", "12345678123456781234567812345678123456781234567812345678123456781", true));
//        print(fileSystem.blocks);
//        System.out.println(Arrays.toString(fileSystem.fat));
//        System.out.println(fileSystem.writeFile("123", "txt", "12345678", false));
//        print(fileSystem.blocks);
//        fileSystem.closeFile("123", "txt");
//        System.out.println(fileSystem.deleteFile("123", "txt"));
//        print(fileSystem.blocks);
//        System.out.println(fileSystem.openFile("123", "txt"));
//        fileSystem.closeFile("123", "txt");
//        fileSystem.closeFile("123", "tat");
//        System.out.println(fileSystem.infoFile("123", "tat"));
//        System.out.println(fileSystem.modifyFile("123", "tat", "321", "txt", 4));
//
//        System.out.println(fileSystem.createDirectory("dev"));
//        System.out.println(fileSystem.createDirectory("bin"));
//        System.out.println(fileSystem.openDirectory("bin"));
//        System.out.println(fileSystem.createDirectory("android"));
//        System.out.println(fileSystem.createFile("111", "txt", 4));
//        System.out.println(fileSystem.openDirectory("android"));
//        System.out.println(fileSystem.createFile("222", "txt", 4));
//
//
//        System.out.println(Arrays.toString(fileSystem.fat));
//        print(fileSystem.blocks);
//
//        System.out.println(fileSystem.root);
//
//
//        printTree(fileSystem.root, "   ");
//
//        showDirectory(fileSystem.root);
//        fileSystem.parent.getPath();
    }

    private static void printTree(MyFile file, String pre) {
        String name = file.getName();
        if (!file.isDirectory()) name += "." + file.getType();
        //System.out.println(name);//
        if (file.getChildList() != null) {
            for (MyFile child : file.getChildList()) {
                //System.out.print(pre);
                printTree(child, pre + pre);
            }
        }
    }

    public static void showDirectory(MyFile file){
        if(file.getChildList()!=null){
            for(MyFile child: file.getChildList()){
                //System.out.println(child);  //todo 业务代码
            }
        }
    }
}
